import ResMgr from "../../Framework/Scripts/Managers/ResMgr";
import SceneMgr from "../../Framework/Scripts/Managers/SceneMgr";
import UIMgr from "../../Framework/Scripts/Managers/UIMgr";
import NetManager from "../../Framework/Scripts/Net/NetManager";
import LoginMgr from "../../Game/Scripts/dataMgr/LoginMgr";
import GameApp from "../../Game/Scripts/GameApp";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Boot extends cc.Component {

    public static Instance: Boot = null;

    onLoad () {
        if(Boot.Instance !== null){
            this.destroy();
            return;
        }
        Boot.Instance = this;

        //常驻节点
        cc.game.addPersistRootNode(this.node);
        this.StartUp();
    }

    start () {

    }

    private async StartUp() {
        await this.CheckHotUpdate();
        await this.InitFramework();
    }

    private CheckHotUpdate() {

    }
 
    private InitFramework() {
        //初始化框架模块
        this.node.addComponent(SceneMgr);
        SceneMgr.Instance.Init();
        // end 
 
        //初始化资源加载模块
        this.node.addComponent(ResMgr);
        ResMgr.Instance.Init();
        //end

        //初始化UI管理器模块
        this.node.addComponent(UIMgr);
        UIMgr.Instance.Init();
        //end

        // 进入游戏
        this.node.addComponent(GameApp);
        GameApp.Instance.Init();
        GameApp.Instance.EnterGame();
        // end 

        this.node.addComponent(NetManager);
        NetManager.Instance.Init();

        this.node.addComponent(LoginMgr);
        LoginMgr.Instance.Init();
    }

}
